<template>
  <!-- 底部部分 -->
  <footer class="footer">
    <span class="todo-count"
      ><strong>{{ listlenght }}</strong
      >剩余</span
    >
    <ul class="filters">
      <li>
        <a :class="{selected:type==='all'}" @click="add('all')" href="#/">全部</a>
      </li>
      <li>
        <a  :class="{selected:type==='active'}" @click="add('active')" href="#/active">进行中</a>
      </li>
      <li>
        <a :class="{selected:type==='completed'}" @click="add('completed')" href="#/completed">已完成</a>
      </li>
    </ul>
    <button class="clear-completed" @click="clearnBtn">清除已完成</button>
  </footer>
</template>

<script>
export default {
  name: 'TodosFooter',
  components: {},
  props: {
    list: {
      type: Array,
      required: true,
    },
    type: {
      type: String,
      required: true,
    },
  },
  data() {
    return {}
  },
  computed: {
    //计算剩余长度
    listlenght() {
      return this.list.filter((item) => item.flag === false).length
    },
  },
  watch: {},
  created() {},
  methods: {
    clearnBtn() {
      this.$emit('clearnBtn')
    },
    add(type){
      this.$emit("add",type)
    }



  },
}
</script>

<style scoped></style>
